package com.dcm.seckill.controller;


import com.dcm.common.annotation.EnableResponseBodyAdvice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author 牛浩
 */
@Api(tags = "seckillOrder")
@RestController
@RequestMapping("/seckillOrder")
@CrossOrigin
@EnableResponseBodyAdvice
public class SeckillOrderController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 开始秒杀
     * @param id
     * @param userName
     */
    @ApiOperation("开始秒杀")
    @GetMapping("startSeckil")
    public void startSeckil(@RequestParam(value = "id",required = false) Long id,
                            @RequestParam(value = "userName",required = false) String userName){
        String msg = userName+"/"+id;
        rabbitTemplate.convertAndSend("seckillEX","seckill",msg);
    }

}
